def allboom(i, j):
    num = 0
    for t in range(8):
        if l[t][0] < 0 or l[t][1] < 0 or l[t][0] >= int(nm[0]) or l[t][1] >= int(nm[1]):
            continue
        else:
            if x[l[t][0]][l[t][1]] == "*":
                num += 1
            else:
                continue
    return num


nm = input().split()
boom_num, x = [], []
for i in range(int(nm[0])):
    x.append(input())

for i in range(int(nm[0])):
    boom_num.append("")
    for j in range(int(nm[1])):
        l = [[i, j - 1], [i - 1, j - 1], [i - 1, j], [i - 1, j + 1], [i, j + 1], [i + 1, j + 1], [i + 1, j],
             [i + 1, j - 1]]
        if x[i][j] == "*":
            boom_num[i] += "*"
        else:
            boom_num[i] += "%d" % allboom(i, j)

for d in boom_num:
    print(d)

